﻿// -----------------------------------------------------------------------
// <copyright file="EnumerableWrapper.cs" company="Zen Design Corp">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

namespace Zen.BlackBerry.Common
{
	using System.Collections;
	using System.Collections.Generic;

	/// <summary>
	/// Helper class that wraps an IEnumerator instance with an IEnumerable
	/// instance.
	/// </summary>
	public class EnumerableWrapper<TElement> : IEnumerable<TElement>
	{
		private IEnumerator<TElement> _enumerator;

		/// <summary>
		/// Initializes a new instance of the <see cref="EnumerableWrapper&lt;TElement&gt;"/> class.
		/// </summary>
		/// <param name="iter">The iter.</param>
		public EnumerableWrapper(IEnumerator<TElement> iter)
		{
			_enumerator = iter;
		}

		#region IEnumerable<TElement> Members

		/// <summary>
		/// Gets the enumerator.
		/// </summary>
		/// <returns></returns>
		public IEnumerator<TElement> GetEnumerator()
		{
			return _enumerator;
		}

		#endregion

		#region IEnumerable Members

		/// <summary>
		/// Returns an enumerator that iterates through a collection.
		/// </summary>
		/// <returns>
		/// An <see cref="T:System.Collections.IEnumerator"/> object that can be used to iterate through the collection.
		/// </returns>
		IEnumerator IEnumerable.GetEnumerator()
		{
			return _enumerator;
		}

		#endregion
	}
}
